package com.tensquare.user.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.tensquare.user.model.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;


public interface UserDao extends JpaRepository<User,String>,JpaSpecificationExecutor<User>{

    User findByMobile(String mobile);

    @Modifying
    @Query(nativeQuery = true,
            value = "UPDATE tb_user SET followcount = followcount + ?1 WHERE id = ?2  ")
    void updateFollowCount(Integer count, String userId);

    @Modifying
    @Query(nativeQuery = true,
            value = "UPDATE tb_user SET fanscount = fanscount + ?1 WHERE id = ?2 ")
    void updateFanCount(Integer count, String friendId);

}
